﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ChongJu.ModelManager.Rating
{
    public class AccountLevelModel
    {
        public string LevelCode { get; set; }

        public string LevelName { get; set; }

        public double TotalWeight
        {
            get
            {
                if (Weights.Exists(q => q.WeightStatus == AccountEnum.Create))
                    return Weights.Where(q => q.WeightStatus == AccountEnum.Create).Sum(q => q.Weight);
                else
                    return Weights.Sum(q => q.Weight);
            }
        }

        public List<AccountWeightModel> Weights { get;  set; } = new List<AccountWeightModel>();

        public AccountLevelModel Clone()
        {
            var data = this.MemberwiseClone() as AccountLevelModel;
            data.Weights = this.Weights.Select(q => q.Clone()).ToList();
            return data;
        }
    }
}
